#ifndef VPGAME_H
#define VPGAME_H

#include "shue.h"

class Shue;
class VPHand;
class VPConnection;
class VPokerSavedGame;
class VPGuts;

class VPGame
{
	public:
		VPGame(VPConnection* conn, int32 bet, bool8 dblUpEnabled);
		VPGame(VPConnection*, VPokerSavedGame*);
		~VPGame();

		bool8 initOk();

		enum DealResults
		{
			DEAL_SUCCESS,
			DEAL_INVALID_BET,
			DEAL_NOT_ENOUGH_MONEY,
			DEAL_CREATE_GAME_FAILURE
		};
		int32 deal();

		enum HoldResults
		{
			HOLD_SUCCESS_GAMEOVER,
			HOLD_SUCCESS_DBLUP_PENDING,
			HOLD_FAILURE
		};
		int32 holdThese(uint8 Cards, uint8);// bits 0..5:  1 if held

		bool8 doubleUpDeny();
		bool8 doubleUpDeal();

		enum DUDrawResults
		{
			DUDRAW_SUCCESS_GAMEOVER,
			DUDRAW_SUCCESS_DBLUP_PENDING,
			DUDRAW_FAILURE
		};
		int32 doubleUpDraw(uint8 held);

		VPHand* getHand();

		int32 getPayFreq();
		bool8 getDoubleUpEnabled();

		void send();
		void save(VPokerSavedGame*);

	protected:
		bool8 restore(VPokerSavedGame*);
		void  delDrawnHands();

	protected:
		VPConnection*	conn;
		VPGuts*			guts;
		ShueGameInfo	sgi;
		Shue*			shue;
		pVPHand			hand;

		int32			bet;
		int32			state;
		int32			dblUpEnabled;
		int32			dblUpPayout;
		int32			dblUpPayType;
		int32			dblUpRound;
		int32			dblUpWon;
		int32			dlbUpCapAmount;
		int32			restoreLastHeld;

		// used to restore "dblup pending" game only (all drawn hands)		
		pVPHand*		cSavHands;
		int32			payouts[100];
		int32			paytypes[100];
		int32			nSavHands;
		
		
		//
		// *IMPORTANT*  When adding/changing here, be sure to update
		//				constructors/destructor, send(), save(), restore()
		//
};

inline VPHand*
VPGame::getHand()
{
	return hand;
}

inline bool8
VPGame::getDoubleUpEnabled()
{
	return (bool8)(dblUpEnabled != 0);
}

#endif
